package cn.com.thingo.hyintelligent.model;

import android.content.SharedPreferences;


import java.util.List;

import cn.com.thingo.hyintelligent.model.bean.BaseBean;
import cn.com.thingo.hyintelligent.model.bean.CommonBean;
import cn.com.thingo.hyintelligent.model.bean.EzAccountBean;
import cn.com.thingo.hyintelligent.model.bean.DoorLockAuthBean;
import cn.com.thingo.hyintelligent.model.bean.EzAddDevicePermissionBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeleteDevicePermissionBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeviceAuthorizationListBean;
import cn.com.thingo.hyintelligent.model.bean.EzDevicePolicyBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeviceStateBean;
import cn.com.thingo.hyintelligent.model.bean.GatewayDetailBean;
import cn.com.thingo.hyintelligent.model.bean.GatewayListBean;
import cn.com.thingo.hyintelligent.model.bean.GetEzTokenBean;
import cn.com.thingo.hyintelligent.model.bean.LoginBean;
import cn.com.thingo.hyintelligent.model.bean.MessageCountBean;
import cn.com.thingo.hyintelligent.model.bean.MessageListBean;
import cn.com.thingo.hyintelligent.model.bean.ModifyHeadBean;
import cn.com.thingo.hyintelligent.model.bean.RegisterBean;
import cn.com.thingo.hyintelligent.model.bean.UserBean;
import cn.com.thingo.hyintelligent.model.http.HttpHelper;
import cn.com.thingo.hyintelligent.model.prefs.PreferencesHelper;
import io.reactivex.Flowable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/10/9.
 */

public class DataManager implements HttpHelper, PreferencesHelper {

    private HttpHelper mHttpHelper;
    private PreferencesHelper mPreferencesHelper;

    public DataManager(HttpHelper httpHelper, PreferencesHelper preferencesHelper) {
        mHttpHelper = httpHelper;
        mPreferencesHelper = preferencesHelper;
    }

    @Override
    public String getUserName() {
        return mPreferencesHelper.getUserName();
    }

    @Override
    public void setUserNameAndPwd(String userName, String pwd) {
        mPreferencesHelper.setUserNameAndPwd(userName, pwd);
    }

    @Override
    public String getPwd() {
        return mPreferencesHelper.getPwd();
    }


    @Override
    public SharedPreferences getSPrefs() {
        return mPreferencesHelper.getSPrefs();
    }

    @Override
    public boolean getLoginState() {
        return mPreferencesHelper.getLoginState();
    }

    @Override
    public void setLoginState(boolean state) {
        mPreferencesHelper.setLoginState(state);
    }

    @Override
    public boolean getRememberPW() {
        return mPreferencesHelper.getRememberPW();
    }

    @Override
    public void setRememberPW(boolean state) {
        mPreferencesHelper.setRememberPW(state);
    }

    @Override
    public boolean getNightModeState() {
        return mPreferencesHelper.getNightModeState();
    }

    @Override
    public void setNightModeState(boolean state) {
        mPreferencesHelper.setNightModeState(state);
    }

    @Override
    public boolean getNoImageState() {
        return mPreferencesHelper.getNoImageState();
    }

    @Override
    public void setNoImageState(boolean state) {
        mPreferencesHelper.setNoImageState(state);
    }

    @Override
    public boolean getAutoCacheState() {
        return mPreferencesHelper.getAutoCacheState();
    }

    @Override
    public void setAutoCacheState(boolean state) {
        mPreferencesHelper.setAutoCacheState(state);
    }

    @Override
    public int getCurrentItem() {
        return mPreferencesHelper.getCurrentItem();
    }

    @Override
    public void setCurrentItem(int item) {
        mPreferencesHelper.setCurrentItem(item);
    }

    @Override
    public boolean getLikePoint() {
        return mPreferencesHelper.getLikePoint();
    }

    @Override
    public void setLikePoint(boolean isFirst) {
        mPreferencesHelper.setLikePoint(isFirst);
    }

    @Override
    public boolean getVersionPoint() {
        return mPreferencesHelper.getVersionPoint();
    }

    @Override
    public void setVersionPoint(boolean isFirst) {
        mPreferencesHelper.setVersionPoint(isFirst);
    }

    @Override
    public boolean getManagerPoint() {
        return mPreferencesHelper.getManagerPoint();
    }

    @Override
    public void setManagerPoint(boolean isFirst) {
        mPreferencesHelper.setManagerPoint(isFirst);
    }

    //获取手机验证码
    @Override
    public Flowable<CommonBean> getCode(String telephone) {
        return mHttpHelper.getCode(telephone);
    }

    //注册
    @Override
    public Flowable<RegisterBean> register(String password, String telephone, String code) {
        return mHttpHelper.register(password, telephone, code);
    }

    @Override
    public Flowable<LoginBean> login(String password, String telephone) {
        return mHttpHelper.login(password, telephone);
    }

    @Override
    public Flowable<GatewayListBean> gatewayList(String token) {
        return mHttpHelper.gatewayList(token);
    }

    @Override
    public Flowable<CommonBean> addGateway(String token, String number, String name, String username, String password) {
        return mHttpHelper.addGateway(token, number, name, username, password);
    }

    @Override
    public Flowable<CommonBean> modifyGateway(String token, String gatewayId, String name) {
        return mHttpHelper.modifyGateway(token, gatewayId, name);
    }

    @Override
    public Flowable<CommonBean> deleteGateway(String token, String gatewayId) {
        return mHttpHelper.deleteGateway(token, gatewayId);
    }

    @Override
    public Flowable<GatewayDetailBean> gatewayDetail(String token, String gatewayId) {
        return mHttpHelper.gatewayDetail(token, gatewayId);
    }

    @Override
    public Flowable<CommonBean> addAuth(String token, String gatewayId, String telephone) {
        return mHttpHelper.addAuth(token, gatewayId, telephone);
    }

    @Override
    public Flowable<CommonBean> delAuth(String token, String gatewayId, String telephone) {
        return mHttpHelper.delAuth(token, gatewayId, telephone);
    }

    @Override
    public Flowable<UserBean> getUser(String token) {
        return mHttpHelper.getUser(token);
    }


    @Override
    public Flowable<ModifyHeadBean> modifyHead(RequestBody token, MultipartBody.Part headPic) {
        return mHttpHelper.modifyHead(token, headPic);
    }

    @Override
    public Flowable<CommonBean> getCodeByModifyPassword(String telephone) {
        return mHttpHelper.getCodeByModifyPassword(telephone);
    }

    @Override
    public Flowable<CommonBean> modifyPassword(String password, String telephone, String code) {
        return mHttpHelper.modifyPassword(password, telephone, code);
    }


    @Override
    public Flowable<BaseBean> createEzAccount(String token, String accountName, String password, String accessToken) {
        return mHttpHelper.createEzAccount(token, accountName, password, accessToken);
    }

    @Override
    public Flowable<EzDeviceStateBean> addEzDevice(String deviceSerial, String validateCode) {
        return mHttpHelper.addEzDevice(deviceSerial, validateCode);
    }

    @Override
    public Flowable<EzDeviceStateBean> deleteEzDevice(String deviceSerial) {
        return mHttpHelper.deleteEzDevice(deviceSerial);
    }

    @Override
    public Flowable<EzDevicePolicyBean> setEzDevicePolicy(String accountId, String policy) {
        return mHttpHelper.setEzDevicePolicy(accountId, policy);
    }

    @Override
    public Flowable<BaseBean> addEzDevicePermission(String accessToken, String tel, String toTel, String statement) {
        return mHttpHelper.addEzDevicePermission(accessToken, tel, toTel, statement);
    }

    @Override
    public Flowable<BaseBean> deleteEzDevicePermission(String accessToken, String tel,String toTel, String deviceSerial) {
        return mHttpHelper.deleteEzDevicePermission(accessToken, tel,toTel, deviceSerial);
    }

    @Override
    public Flowable<BaseBean<List<EzDeviceAuthorizationListBean>>> getEzDeviceAuthorzationList(String accessToken,String tel, String toTel) {
        return mHttpHelper.getEzDeviceAuthorzationList(accessToken,tel, toTel);
    }

    @Override
    public Flowable<BaseBean<String>> getAdminEzToken(String token, String secret, String appkey) {
        return mHttpHelper.getAdminEzToken(token, secret, appkey);
    }

    @Override
    public Flowable<BaseBean<EzAccountBean>> getSonAccountMsg(String token, String accessToken) {
        return mHttpHelper.getSonAccountMsg(token, accessToken);
    }

    @Override
    public Flowable<CommonBean> addDoorLockAuth(String token, String gatewayId, String telephone) {
        return mHttpHelper.addDoorLockAuth(token, gatewayId, telephone);
    }

    @Override
    public Flowable<CommonBean> delDoorLockAuth(String token, String gatewayId, String telephone) {
        return mHttpHelper.delDoorLockAuth(token, gatewayId, telephone);
    }

    @Override
    public Flowable<DoorLockAuthBean> doorLockAuthList(String token, String gatewayId) {
        return mHttpHelper.doorLockAuthList(token, gatewayId);
    }

    @Override
    public Flowable<CommonBean> addMessage(String token, String title, String content) {
        return mHttpHelper.addMessage(token, title, content);
    }

    @Override
    public Flowable<MessageListBean> messageList(String token) {
        return mHttpHelper.messageList(token);
    }

    @Override
    public Flowable<MessageCountBean> messageCount(String token) {
        return mHttpHelper.messageCount(token);
    }

    @Override
    public Flowable<CommonBean> readMessage(String token, String messageId) {
        return mHttpHelper.readMessage(token, messageId);
    }

    @Override
    public Flowable<CommonBean> logout(String token) {
        return mHttpHelper.logout(token);
    }


}
